﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Xml;
using JumbotCms.Common;

namespace JumbotCms.WebFile.Customer
{
    public partial class _vipapply_index : JumbotCms.API.UserCenter
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            User_Load("", "html");
            if (q("act") != "save")
            {
                Response.Write(GetPageHtml("customer_vipapply"));
            }
            else
            {
                if (!CheckFormUrl())
                    Response.End();
                doh.Reset();
                doh.ConditionExpress = "UserId=@userid and applytype=3 and checked=0";
                doh.AddConditionParameter("@userid", UserId);
                if (doh.Count("jcms_normal_user_apply") > 0)
                    Response.Write("JumbotCms.Alert('请不要重复申请', '0');");
                else
                {

                    doh.Reset();
                    doh.AddFieldItem("UserId", UserId);
                    doh.AddFieldItem("ApplyInfo", "申请" + Str2Int(f("ddlYears")) + "年VIP服务");
                    doh.AddFieldItem("ApplyType", 3);
                    doh.AddFieldItem("ApplyNumber", Str2Int(f("ddlYears")));
                    doh.AddFieldItem("ApplyTime", DateTime.Now.ToString());
                    doh.AddFieldItem("ApplyIP", GetUserIp());
                    doh.AddFieldItem("Checked", 0);
                    doh.Insert("jcms_normal_user_apply");
                    string _mailBody = "ID：[" + UserId + "]，用户名[" + UserName + "]的会员于" + DateTime.Now.ToString() + "申请" + Str2Int(f("ddlYears")) + "年VIP服务，请尽快核实汇款/转账信息，并帮其开通服务";
                    if (SendServiceNotice(site.Name + "会员申请" + Str2Int(f("ddlYears")) + "年VIP服务", _mailBody, Str2Str(f("ddlNoticeMode"))))
                        Response.Write("JumbotCms.Alert('申请成功,请尽快选择一种方式付款,然后与客服联系,请求受理', '1', \"window.location='../customer_index/index.aspx?mod=customer';\");");
                    else
                        Response.Write("JumbotCms.Alert('申请成功,请尽快选择一种方式付款,然后与客服联系,请求受理', '1', \"window.location='../customer_index/index.aspx?mod=customer';\");");
                }
            }
        }
    }
}
